package com.gvfish.entity;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;

/**
 * 
 * 文章分类
 * 
 */
@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class Category implements Serializable {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	@PrimaryKey
	@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
	private Long id;
	@Persistent
	private String name;
	@Persistent
	private String description;
	@Persistent
	private String metaTitle;
	@Persistent
	private String metaKeyWords;
	@Persistent
	private String metaDescription;
	
	@Persistent
	private Integer artCount=0;
	
	@Persistent
	private Boolean hasChild;// 是否有子节点
	@Persistent
	private Integer depth;// 树的深度

	@Persistent
	private Long parentId;
	
	@Persistent
	private Enum<CatKind> catKind;

	@Persistent
	private List<Article> articles = new ArrayList<Article>();
	
	@Persistent
	private List<Picture> pictures=new ArrayList<Picture>();
	

	public enum CatKind {
		Aricle,Picture;
	}
	
	public Category() {

	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public void setHasChild(Boolean hasChild) {
		this.hasChild = hasChild;
	}

	public Boolean getHasChild() {
		return hasChild;
	}

	// public void setArticles(List<Article> articles) {
	// this.articles = articles;
	// }
	//
	// public List<Article> getArticles() {
	// return articles;
	// }

	public void setName(String name) {
		this.name = name;
	}

	public String getName() {
		return name;
	}

	public String getMetaTitle() {
		return metaTitle;
	}

	public void setMetaTitle(String metaTitle) {
		this.metaTitle = metaTitle;
	}

	public String getMetaKeyWords() {
		return metaKeyWords;
	}

	public void setMetaKeyWords(String metaKeyWords) {
		this.metaKeyWords = metaKeyWords;
	}

	public String getMetaDescription() {
		return metaDescription;
	}

	public void setMetaDescription(String metaDescription) {
		this.metaDescription = metaDescription;
	}

	public void setDepth(Integer depth) {
		this.depth = depth;
	}

	public Integer getDepth() {
		return depth;
	}

	@Override
	public String toString() {
		return ToStringBuilder.reflectionToString(this);
	}
	@Override
	public boolean equals(Object o) {
		return (o instanceof Category) && ((Category) o).getId().equals(id);
	}
	@Override
	public int hashCode() {
		HashCodeBuilder hb = new HashCodeBuilder();
		hb.append(id);
		hb.append(name);
		return hb.toHashCode();
	}

	public void setArticles(List<Article> articles) {
		this.articles = articles;
	}

	public List<Article> getArticles() {
		return articles;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public Long getId() {
		return id;
	}

	public void setParentId(Long parentId) {
		this.parentId = parentId;
	}

	public Long getParentId() {
		return parentId;
	}

	public void setArtCount(Integer artCount) {
		this.artCount = artCount;
	}

	public Integer getArtCount() {
		return artCount;
	}

	public void setPictures(List<Picture> pictures) {
		this.pictures = pictures;
	}

	public List<Picture> getPictures() {
		return pictures;
	}


	public void setCatKind(Enum<CatKind> catKind) {
		this.catKind = catKind;
	}

	public Enum<CatKind> getCatKind() {
		return catKind;
	}

}
